package top.z.orm.core.osql;

import java.util.List;

/**
 * 多表查询
 * <p>
 * example:
 * <p>
 * public class Orders{
 * <p>	private Long id;
 * <p>	private String userid;
 * <p>	private String name;
 * <p>	private BigDecimal total;
 * <p>	private Timestamp createtime;
 * <p>	private String remark;
 * <p>	private String sequence;
 * <p>
 * <p>//@JoinTable(mainField="userid", subField="username")
 * <p>//@JoinTable(mainField="userid", subField="username", joinType=JoinType.LEFT_JOIN)  //ok //... from orders left join user on orders.userid=user.username where ...
 * <p>	@JoinTable(mainField="userid,name", subField="username,name", joinType=JoinType.JOIN)
 * <p>//@JoinTable(mainField="userid", subField="username",subAlias="myuser" , joinType=JoinType.FULL_JOIN)
 * <p>//@JoinTable()
 * <p>	private User user;
 * <p>
 * <p>	// ... get,set methods.
 * <p>	 }
 * <p>
 * <p>	 public class User {
 * <p>
 * <p>	private Long id;
 * <p>	private String email;
 * <p>	private String lastName;
 * <p>	private String name;
 * <p>	private String password;
 * <p>	private String username;
 * <p>	private Timestamp createtime;
 * <p>
 * <p>		// ... get,set methods.
 * <p>	 }
 * <p>
 * <p>public class MoreTableExam {
 * <p>
 * <p>	public static void main(String[] args) {
 * <p>		MoreTable moreTable=BeeFactory.getHoneyFactory().getMoreTable();
 * <p>
 * <p>	 	Orders orders1=new Orders();
 * <p>		orders1.setUserid("bee");
 * <p>		orders1.setName("Bee(ORM Framework)");
 *
 * <p>		User user=new User();
 * <p>		user.setEmail("beeUser@163.com");
 * <p>		orders1.setUser(user);
 * <p>	    List<Orders> list1 =moreTable.select(orders1);       //select
 * <p>//	List<Orders> list1 =moreTable.select(orders1,0,10);  //select,paging
 * <p>	    //... process list1
 * <p>	    }
 * <p>	 }
 */
public interface MoreTable {

    /**
     * 根据实体对象entity查询数据
     *
     * @param entity 与表对应的实体对象,且不能为空,entity中非null且非空字符串作为过虑条件,操作符是等号.eg:field=value
     * @return 返回可包含多个实体(多条记录)的list. return list can contain more than one entity
     */
    <T> List<T> select(T entity);

    /**
     * 根据实体对象entity查询数据
     *
     * @param entity 实体类对象,且不能为空. table's entity(do not allow null),entity中非null且非空字符串作为过虑条件,操作符是等号.eg:field=value
     * @param start  开始下标(从0或1开始,eg:MySQL是0,Oracle是1)
     * @param size   结果集大小,大于等于1
     * @return 返回可包含多个实体(多条记录)的list
     */
    <T> List<T> select(T entity, int start, int size);

    /**
     * 根据实体对象和Condition查询数据
     *
     * @param entity    与表对应的实体对象,且不能为空
     * @param condition entity默认有值的字段会转成field=value的形式,其它形式可通过condition指定.condition使用过的字段,默认情况不会再处理
     *                  若condition没有设置IncludeType,默认过滤NULL和空字符串(但condition中op,between,notBetween方法设置的字段,不受includeType的值影响.)
     * @return 返回可包含多个实体(多条记录)的list
     */
    <T> List<T> select(T entity, Condition condition);
}